<template>
	<view class="container">
		<view class="box1">
		</view>
		<view class="box2">
			<view class="btn-Box">
				<view class="btn-Box-item-wrap">
					<view class="btn-Box-item" @click="scan">
						<image src="https://pili-vod.guanxikeji.com/hemashangcheng/img/1732260649185.png" mode=""></image>
						<text>店内就餐</text>
						<view class="tips2">扫桌面二维码下单</view>
					</view>
					<view class="btn-Box-item" @click="goorder(1)">
						<image src="https://pili-vod.guanxikeji.com/hemashangcheng/img/1732260624615.png" mode=""></image>
						<text>到店自取</text>
						<view class="tips2">在线点餐 到店自取</view>
					</view>
				</view>
				<view class="btn-Box-item-wrap">
					<view class="btn-Box-item" @click="goorder(2)">
						<image src="https://pili-vod.guanxikeji.com/hemashangcheng/img/1732260642472.png" mode=""></image>
						<text>外卖下单</text>
						<view class="tips2">在线点餐 外送到家</view>
					</view>
					<view class="btn-Box-item" @click="$goURl('/pages/Lochig/pizzahut/order')">
						<image src="https://pili-vod.guanxikeji.com/hemashangcheng/img/1732260631563.png" mode=""></image>
						<text>我的订单</text>
					</view>
				</view>
			</view>
		</view>
		<view class="box3">
			<view>本产品为第三方点餐服务</view>
			<view>即第三方平台代下单服务与必胜客官方无关</view>
		</view>
	</view>
</template>
<script setup>
	import {
		ref,
		reactive,
		getCurrentInstance
	} from "vue";
	import {
		onLoad,
		onShow
	} from "@dcloudio/uni-app";
	const {
		proxy
	} = getCurrentInstance();
	onShow(() => {
		uni.$on('scanCode', (info) => { //开启监听全局的地址改变事件
			const urlObj = new URL(info);
			// 使用URLSearchParams解析查询参数
			const params = new URLSearchParams(urlObj.search);
			// 获取storecode的值
			const storecode = params.get('storecode');	
			uni.setStorageSync('pizzahuturl', info)
			console.log(info,"info")
				setTimeout(() => {
					uni.navigateTo({
						url: `/pages/Lochig/pizzahut/selectDrink?id=${storecode}`
					})
				}, 200)
			})
	})
	//去下单
	function goorder(e) {
		uni.setStorageSync('pizzahuttype', e)
		if(e == 1){
			uni.navigateTo({
				url:'/pages/Lochig/pizzahut/Selectstore'
			})
		}else{
			uni.navigateTo({
				url:'/pages/Lochig/pizzahut/selectDrink'
			})
		}
	}
	// 扫码
	function scan() {
		uni.setStorageSync('pizzahuttype', 0)
			uni.navigateTo({
				url: '/pages/ScanCode/ScanCode'
			})		
			
			// 定义URL
			// const url = "https://order.pizzahut.com.cn/phdi_mos/welcome?storecode=WH2744&p=0b39f4b9fc3119be2a23419731c19698b782f8f6c83eb52e8951053c1e7e779f";
			// const urlObj = new URL(url);
			// // 使用URLSearchParams解析查询参数
			// const params = new URLSearchParams(urlObj.search);
			// // 获取storecode的值
			// const storecode = params.get('storecode');	
			// uni.setStorageSync('pizzahuturl', url)
			// 	setTimeout(() => {
			// 		uni.navigateTo({
			// 			url: `/pages/Lochig/pizzahut/selectDrink?id=${storecode}`
			// 		})
			// 	}, 200)
			
	}

</script>


<style scoped lang="scss">
	.container {
		.box1 {
			background-image: url("https://pili-vod.guanxikeji.com/hemashangcheng/img/1732260637192.png");
			background-size: 100% 100%;
			background-repeat: no-repeat;
			width: 100%;
			height: 700rpx;
		}

		.box2 {
			padding: 0px 30rpx;
			margin-top: -100rpx;

			.btn-Box {
				width: 100%;
				height: 378px;
				background: #fff;
				border-radius: 11px;
				display: flex;

				.btn-Box-item-wrap:nth-child(1) {
					border-right: 0.5px solid #f2f2f2;
				}

				.btn-Box-item-wrap {
					width: 50%;
					height: 100%;

					.btn-Box-item {
						width: 100%;
						height: 50%;
						display: flex;
						flex-direction: column;
						justify-content: center;
						align-items: center;

						.tips2 {
							font-size: 10px;
							color: rgba(0, 0, 0, .45);
							font-weight: 400;
							margin-top: 5px;
						}

						image {
							width: 110px !important;
							height: 110px !important;
						}

						text {
							font-size: 15px;
							font-family: PingFangSC-Medium, PingFang SC;
							font-weight: 500;
							color: rgba(0, 0, 0, .85);
							line-height: 22px;
							margin-top: 11px;
						}
					}
				}
			}

		}

		.box3 {
			margin-top: 50px;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			font-size: 13px;
			font-family: PingFang-SC-Medium, PingFang-SC;
			font-weight: 500;
			color: rgba(0, 0, 0, .45);
		}
	}

	.btn-Box-item-wrap:nth-child(1)>.btn-Box-item:nth-child(2),
	.btn-Box-item-wrap:nth-child(2)>.btn-Box-item:nth-child(2) {
		border-top: 0.5px solid #f2f2f2;
	}
</style>